<!--
 * @Descripttion: 
 * @Author: zhanyi
 * @Date: 2021-10-28 09:15:58
 * @FilePath: \wczd-mobile\src\pages\my-info\my-message.vue
-->
<template>
  <div class="my-message">
    <secondTopPanel>
      <div slot='title'>我的消息</div>
    </secondTopPanel>
    <div class="message-box">
      <zPaging class="_sxwh_box" :default-page-size="10" :fixed='false' :height="'100%'" ref="paging" @query="queryList" v-model="messageList" :delay='200' :refresher-end-bounce-enabled="false">
        <div class="boxitem" v-for="(item,index) in messageList" :key="index">
          <div class="title">{{item.msgType}}
            <div class="isReady" v-if="item.isread==='0'"></div>
          </div>
          <div class="content">{{item.msg}}</div>
          <div class="footer" @click="_checkInfo(item)">
            <span>查看</span>
            <image class="_image_icon" src="@/static/wczd/more.png" alt=""></image>
          </div>
        </div>
      </zPaging>
    </div>
  </div>
</template>

<script>
import secondTopPanel from '@/pages/component/top-panel/secondTopPanel.vue'
import { msgListToMine, msgInfoEdit } from "@/api/user";
import zPaging from '@/uni_modules/z-paging/components/z-paging/z-paging.vue'
import ZPagingMixin from '@/uni_modules/z-paging/components/z-paging/js/z-paging-mixin'
import customNomore from '@/pages/component/custom-nomore/custom-nomore.vue'

export default {
  name: 'my-message',
  components: { secondTopPanel, zPaging, customNomore },
  mixins: [ZPagingMixin],
  data () {
    return {
      messageList: []
    }
  },
  methods: {
    // z-paging 查询方法
    queryList (pageNo, pageSize) {
      console.log(pageNo, pageSize);
      uni.showLoading({
        title: '加载中'
      });
      msgListToMine({}, { pageNum: pageNo, pageSize: pageSize }).then(res => {
        this.$refs.paging.complete(res.rows)
        uni.hideLoading();
      })
    },
    // 点击查看修改已读 跳转详情页
    _checkInfo (item) {
      if (item.isread === '0') {
        msgInfoEdit({ id: item.id, userId: item.userId, isread: '1' }).then(res => {
          console.log('标记已读');
          this.queryList(1, 10)
        })
      }
      uni.navigateTo({
        url: `/pages/my-info/my-message-detil?id=${item.id}`
      })
    }
  },
}
</script>

<style scoped lang="scss">
.my-message {
  height: 100%;
  .message-box {
    height: 100%;
    padding: 100upx 0 30px 0;
    .boxitem {
	  margin: auto;
	  width: 95%;
      margin-top: 40upx;
      background-color: #fff;
      padding: 15upx 30upx 15upx 30upx;
      border-radius: 10upx;
      display: flex;
      flex-direction: column;
      .isReady {
        width: 20upx;
        height: 20upx;
        background-color: #f54a13;
        margin-top: -20upx;
        border-radius: 50%;
        margin-left: 10upx;
      }
      .title {
        display: flex;
        align-items: center;
        padding-left: 20upx;
        font-size: 30upx;
        font-weight: bold;
        &::before {
          content: "";
          position: relative;
          left: -20upx;
          height: 30upx;
          width: 3upx;
          border-left: 3px solid #009fdf;
        }
      }
      .content {
        flex: 1;
        color: #8d9093;
        padding: 10upx 0;
      }
      .footer {
        padding: 10upx 0 0 0;
        border-top: 1px solid #e8e9e9;
        span {
          float: left;
          font-weight: bold;
          color: #009fdf;
          font-size: 30upx;
        }
        image {
          float: right;
        }
      }
    }
  }
}
</style>
